package com.whale.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.whale.constants.MenuGroupConstants;
import com.whale.kernel.domain.UserAccount;
import com.whale.kernel.service.TestService;

/**
 * Handles requests for the application home page.
 */
@Controller
public class HomeController extends AbstractController {
	
	private TestService testService;

	public void setTestService(TestService testService) {
		this.testService = testService;
	}
	
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public String home(Model model) {
		populateNavigation(model, "/", MenuGroupConstants.USER_MENU_GROUP_ID);
		return "home";
	}

	@RequestMapping(value = "/test", method = RequestMethod.POST)
	public String create(HttpServletRequest request,
			@Valid UserAccount userAccount, BindingResult result, Model model) {
		testService.mytest();
		return "redirect:/";
	}

}
